package cn.tedu.spring.config;

import cn.tedu.spring.di.UserService;
import cn.tedu.spring.eg1.Product;
import cn.tedu.spring.file.Database;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestSpringConfig {
    public static void main(String[] args) {
//        1.基于注解方式创建Ioc容器--->Ioc Init
        AnnotationConfigApplicationContext context=
                new AnnotationConfigApplicationContext(SpringConfig.class);
//        获取到Database的对象
        Database database = context.getBean(Database.class);
        System.out.println("database = " + database);

//        获取到Product对象
        Product product = context.getBean(Product.class);
        System.out.println("product = " + product);

//        关闭Ioc容器
        context.close();
    }
}
